/****************************** (C) COPYRIGHT 2016 RSEStudio ****************************
* File Name          : 
* Author             : RSES_Liyang
* Version            : V1.0.0
* Date               : 00-May-18
* Description        : 
*****************************************************************************************/
/* Includes ----------------------------------------------------------------------------*/
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include <string.h>
#include "Bsp.h"
#include "SGUI_Basic.h"
#include "HMI_Engine.h"
#include "UI.h"
#include "Font.h"
#include "UI_Welcome.h"
#include "UI_MainPage.h"
#include "UI_Measure.h"
#include "UI_SelectStart.h"
#include "UI_CondStart.h"
#include "UI_PowerOff.h"
#include "UI_Alarm.h"
#include "UI_OffCharge.h"
#include "UI_USBLink.h"
#include "UI_PreStart.h"
/* Extern variables --------------------------------------------------------------------*/
/* Private define ----------------------------------------------------------------------*/
SGUI_SCR_DEV 	dummy_dev;
/* Private macro -----------------------------------------------------------------------*/
/* Private typedef ---------------------------------------------------------------------*/
/* Private variables -------------------------------------------------------------------*/

HMI_SCREEN_OBJECT*		UIScreen_List[] = 
{
	&UI_Welcome,
	&UI_MainPage,
	&UI_CondStart,
	&UI_Measure,
	//&UI_PowerOff,
	//&UI_Alarm,
	&UI_OffCharge,
	&UI_USBLink,
    &UI_TcInsert,
    &UI_PreStart,
};

HMI_ENGINE_OBJECT		UIEngine;
/* Private functions -------------------------------------------------------------------*/
void UITimer_100ms_EventProc(void *Parameter);


HMI_ENGINE_RESULT	UIEngine_Init(void)
{
	HMI_ENGINE_RESULT	ProcessResult;
	int 				iIndex;
	
	ProcessResult = 	HMI_RET_NORMAL;
	
	memset(&UIEngine, 0x00, sizeof(HMI_ENGINE_OBJECT));
	
	UIEngine.ScreenCount = sizeof(UIScreen_List)/sizeof(*UIScreen_List);
	UIEngine.ScreenObjPtr = UIScreen_List;
	UIEngine.Interface = &dummy_dev;
	
	do
	{
		if(UIEngine.ScreenObjPtr != NULL)
		{
			for(iIndex = 0;iIndex<UIEngine.ScreenCount;iIndex++)
			{
				if((UIEngine.ScreenObjPtr[iIndex]!=NULL)
					&&(UIEngine.ScreenObjPtr[iIndex]->pstActions!=NULL)
					&&(UIEngine.ScreenObjPtr[iIndex]->pstActions->Initialize!=NULL))
				{
					UIEngine.ScreenObjPtr[iIndex]->pstActions->Initialize(&dummy_dev);
					UIEngine.ScreenObjPtr[iIndex]->pstPrevious = NULL;
				}
			}
		}
		
		ProcessResult = HMI_ActiveEngine(&UIEngine,UI_SCREEN_ID_WELCOME);		
		if(HMI_PROCESS_FAILED(ProcessResult))
		{
			break;
		}
		
		ProcessResult = HMI_StartEngine(NULL);
		if(HMI_PROCESS_FAILED(ProcessResult))
		{
			break;
		}
	}while(0);
	
	return ProcessResult;
}
//


/*****************************************************************************************
* Function Name  : SGUI_Clear
* Description    : 
* Input          : None
* Output         : None
* Return         : None
*****************************************************************************************/	
void SGUI_Clear(void)
{
}
//

/*****************************************************************************************
* Function Name  : SGUI_Clear
* Description    : 
* Input          : None
* Output         : None
* Return         : None
*****************************************************************************************/	
SGUI_INT SGUI_Initialize(void)
{
	return 0;
}
//

/*****************************************************************************************
* Function Name  : SGUI_GetPoint
* Description    : 
* Input          : None
* Output         : None
* Return         : None
*****************************************************************************************/
SGUI_INT SGUI_GetPixel(SGUI_INT x,SGUI_INT y)
{	
	return 0;
}
//


/*****************************************************************************************
* Function Name  : SGUI_DrawPoint
* Description    : 
* Input          : None
* Output         : None
* Return         : None
*****************************************************************************************/	
void SGUI_DrawPixel(SGUI_INT x,SGUI_INT y,SGUI_INT color)
{
}
//

/*****************************************************************************************
* Function Name  : SGUI_Refresh
* Description    : 
* Input          : None
* Output         : None
* Return         : None
*****************************************************************************************/
void SGUI_SyncBuffer(void)
{
}
//

/*****************************************************************************************
* Function Name  : 
* Description    : 
* Input          : None
* Output         : None
* Return         : None
*****************************************************************************************/
void UI_init(void)
{
	
	dummy_dev.stSize.iWidth = 0;
	dummy_dev.stSize.iHeight = 0;
	dummy_dev.fnClear = SGUI_Clear;
	dummy_dev.fnGetPixel = SGUI_GetPixel;
	dummy_dev.fnInitialize = SGUI_Initialize;
	dummy_dev.fnSetPixel = SGUI_DrawPixel;
	dummy_dev.fnSyncBuffer = SGUI_SyncBuffer;
	dummy_dev.stBuffer.sSize = 0;
	dummy_dev.stBuffer.pBuffer = 0;

	UIEngine_Init();
}

//
/********************************(C)COPYRIGHT 2016 RSEStudio ****************************/
/*****************************************END OF FILE************************************/
